﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpDemo._02_对象和类型
{
    class Construct
    {
        //服务器地址,数据库名称 ， 用户名，密码
        public static string Address;
        public static string DataBase;
        public string Name;
        public string Password;

        public static void Test() {
            Console.WriteLine("\n构造函数测试");
            Console.WriteLine("数据库地址:" + Construct.Address);
            Console.WriteLine("数据库名称:" + Construct.DataBase);
            Construct connect = new Construct("95938");
            Console.WriteLine("用户名:" + connect.Name);
            Console.WriteLine("密码:" + connect.Password);
        }

        //1.静态构造函数(无返回值，无参数, 加载类时调用)
         static Construct()
        {
            Address = "10.5.107.38";
            DataBase = "202High";
        }

        //2.普通构造函数
        public Construct(string Name, string Password)
        {
            this.Name = Name;
            this.Password = Password;
        }

        //3.构造函数初始化器(在构造函数中调用构造函数)
        public Construct(string Password)
            : this("sa", Password)
        {

        }



    }
}
